const request = eval('require')('request');
const eventClass = require('./eventClass');

class requestClass extends eventClass {
    constructor() {
        super('requestClass');
    }

    get(cb, { url, headers, form }) {
        const this_ = this;
        request.get({
            url,
            headers,
            form,
        }, (err, res, body) => {
            cb(err, res, body);
            this_.returnMethod(cb, {
                err,
                data: {
                    body,
                    res,
                },
            });
        });
    }

    post(cb, { url, headers, form }) {
        const this_ = this;
        request.post({
            url,
            headers,
            form,
        }, (err, res, body) => {
            cb(err, res, body);
            this_.returnMethod(cb, {
                err,
                data: {
                    body,
                    res,
                },
            });
        });
    }
}

module.exports = requestClass;
